// Copyright 2009 Pigasus.
// GNU GPL v2.
// Author: John Zhang and Jordan Rupprecht.
//
// Functions to facilitate casting between types. 

#ifndef CAST_H_ 
#define CAST_H_

#include <string>

#include "pigasus-types.h"

using namespace std;

// Cast a C++ type to an int.
int CastToInt(const int &v);
int CastToInt(const double &v);
int CastToInt(const string &v);

// Cast a C++ type to a double (Pigasus float).
double CastToFloat(const int &v);
double CastToFloat(const double &v);
double CastToFloat(const string &v);

// Cast a C++ type to a string.
string CastToString(const int &v);
string CastToString(const double &v);
string CastToString(const string &v);

// Cast a string to File; the only way to create a File in Pigasus.
File CastToFile(const string &v);

// Use the following casting functions when casting the result of List.Get() or
// Map.Get().
int CastToInt(void *v);
double CastToFloat(void *v);
string CastToString(void *v);
List CastToList(void *v);
Map CastToMap(void *v);
File CastToFile(void *v);

// Allow Lists, Files and Maps to cast to themselves.
List CastToList(const List &v);
Map CastToMap(const Map &v);
File CastToFile(const File &v);

#endif  // CAST_H_
